dynamic class com.c3d.mediaRotator.display.PanelView extends MovieClip
{
    var _hitAreaInterval;
    var _panelController;
    var _subViewIdentifier;
    var _viewPanelAssetWrapper;
    var _viewPanelHitArea;
    var _viewPanelMask;
    var _viewPanelMovieClip;
    var _viewReadyInterval;

    function PanelView($panelController, $viewParentMovieClip)
    {
        super();
        this._panelController = $panelController;
        this._subViewIdentifier = this.generateViewIdentifier();
        this.attachView($viewParentMovieClip);
    }

    function activate()
    {
        this._viewPanelMovieClip._visible = true;
    }

    function deactivate()
    {
        this._viewPanelMovieClip._visible = false;
    }

    function generateViewIdentifier()
    {
        var __reg3 = "";
        var __reg2 = Math.round(Math.random() * 1000000);
        return this._panelController.__get__subControllerIdentifier() + "_" + __reg2.toString();
    }

    function attachView($parentMovieClip)
    {
        this._viewPanelMovieClip = $parentMovieClip.attachMovie("panelView_mc", "_viewPanelMovieClip_" + this.__get__subViewIdentifier(), $parentMovieClip.getNextHighestDepth());
        this._viewReadyInterval = setInterval(mx.utils.Delegate.create(this, this.checkViewMCInitStatus), 500);
        if (this._panelController.__get__parentController() == null) 
        {
            if (this._panelController.__get__baseController() != null) 
            {
                var __reg2 = this._panelController.__get__baseController().__get__bannerGlobalConfigParams().stageSize;
                this.rerenderHitArea(this.rerenderHitArea, null, __reg2);
            }
            return;
        }
        this._hitAreaInterval = setInterval(mx.utils.Delegate.create(this, this.rerenderHitArea), 500);
    }

    function checkViewMCInitStatus()
    {
        if (this._viewPanelMovieClip.isReady) 
        {
            clearInterval(this._viewReadyInterval);
            this.onPanelViewInitialized();
            return;
        }
    }

    function onPanelViewInitialized()
    {
        this._viewPanelAssetWrapper = this._viewPanelMovieClip.createEmptyMovieClip("_viewPanelAssetWrapper", this._viewPanelMovieClip.getNextHighestDepth());
        if (this._panelController.__get__maskInformation() != null) 
        {
            this.drawMask(this._panelController.__get__maskInformation());
        }
        if (this._panelController.__get__locationInformation() != null) 
        {
            this._viewPanelMovieClip._x = this._panelController.__get__locationInformation().x;
            this._viewPanelMovieClip._y = this._panelController.__get__locationInformation().y;
        }
        if (this._panelController.__get__effectInformation().length > 0) 
        {
            this.applyEffects(this._viewPanelAssetWrapper, this._panelController.__get__effectInformation());
        }
        if (this._panelController.__get__linkInformation() != null) 
        {
            if (this._panelController.__get__panelAssetExtension() != "swf") 
            {
                this.applyButton(this._viewPanelAssetWrapper);
            }
        }
        if (this._panelController.__get__strokeInformation() != null) 
        {
            this.drawStroke(this._panelController.__get__strokeInformation());
        }
        this._viewPanelHitArea = this.drawViewPanelHitArea(this._viewPanelMovieClip, this._viewPanelAssetWrapper);
        this._panelController.internal_eventDispatcher.dispatchEvent({type: "subviewReady", target: this});
    }

    function render()
    {
    }

    function applyButton($buttonTarget)
    {
        $buttonTarget.onPress = mx.utils.Delegate.create(this, this.onPanelPress);
        $buttonTarget.onRelease = mx.utils.Delegate.create(this, this.onPanelRelease);
        $buttonTarget.onRollOver = mx.utils.Delegate.create(this, this.onPanelRollover);
        $buttonTarget.onRollOut = mx.utils.Delegate.create(this, this.onPanelRollout);
        $buttonTarget.onDragOut = mx.utils.Delegate.create(this, this.onPanelRollout);
    }

    function onPanelPress($event)
    {
        if (com.c3d.mediaRotator.transitions.PanelTransitionManager.__get__TRANSITION_IN_PROGRESS()) 
        {
            return;
        }
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.mediaRotator.events.PanelEvent.PANEL_PRESS, target: this, urlRequest: {href: this._panelController.__get__linkInformation().href, target: this._panelController.__get__linkInformation().target}});
    }

    function onPanelRelease($event)
    {
        if (com.c3d.mediaRotator.transitions.PanelTransitionManager.__get__TRANSITION_IN_PROGRESS()) 
        {
            return;
        }
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.mediaRotator.events.PanelEvent.PANEL_RELEASE, target: this});
    }

    function onPanelRollover($event)
    {
        if (com.c3d.mediaRotator.transitions.PanelTransitionManager.__get__TRANSITION_IN_PROGRESS()) 
        {
            return;
        }
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.mediaRotator.events.PanelEvent.PANEL_ROLLOVER, target: this});
    }

    function onPanelRollout($event)
    {
        if (com.c3d.mediaRotator.transitions.PanelTransitionManager.__get__TRANSITION_IN_PROGRESS()) 
        {
            return;
        }
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.mediaRotator.events.PanelEvent.PANEL_ROLLOUT, target: this});
    }

    function applyEffects($effectTarget, $effectParameters)
    {
        var __reg9 = new Array();
        __reg9 = $effectTarget.filters;
        var __reg1 = 0;
        while (__reg1 < $effectParameters.length) 
        {
            if ((__reg0 = $effectParameters[__reg1].type) === "dropshadow") 
            {
                var __reg8 = new flash.filters.DropShadowFilter();
                __reg9.push(__reg8);
            }
            else if (__reg0 === "glow") 
            {
                var __reg5 = 16777215;
                var __reg6 = 100;
                var __reg3 = 5;
                var __reg4 = 5;
                if ($effectParameters[__reg1].color) 
                {
                    __reg5 = $effectParameters[__reg1].color;
                }
                if ($effectParameters[__reg1].alpha) 
                {
                    __reg6 = $effectParameters[__reg1].alpha;
                }
                if ($effectParameters[__reg1].blurx) 
                {
                    __reg3 = $effectParameters[__reg1].blurx;
                }
                if ($effectParameters[__reg1].blury) 
                {
                    __reg4 = $effectParameters[__reg1].blury;
                }
                var __reg7 = new flash.filters.GlowFilter(__reg5, __reg6, __reg3, __reg4);
                __reg9.push(__reg7);
            }
            ++__reg1;
        }
        $effectTarget.filters = __reg9;
    }

    function drawStroke($strokeParameters)
    {
    }

    function get subViewIdentifier()
    {
        return this._subViewIdentifier;
    }

    function get viewMovieClip()
    {
        return this._viewPanelMovieClip;
    }

    function get assetWrapper()
    {
        return this._viewPanelAssetWrapper;
    }

    function drawViewPanelHitArea($targetClip, $sizeClue, $size)
    {
        var __reg1 = $targetClip.createEmptyMovieClip("clipHitArea_mc", $targetClip.getNextHighestDepth());
        var __reg3 = undefined;
        var __reg2 = undefined;
        if ($sizeClue == null && $size) 
        {
            __reg3 = $size.x;
            __reg2 = $size.y;
        }
        else 
        {
            __reg3 = $sizeClue._width;
            __reg2 = $sizeClue._height;
        }
        __reg1.beginFill(16763904, 0);
        __reg1.moveTo(0, 0);
        __reg1.lineTo(__reg3, 0);
        __reg1.lineTo(__reg3, __reg2);
        __reg1.lineTo(0, __reg2);
        __reg1.lineTo(0, 0);
        __reg1.endFill();
        return __reg1;
    }

    function drawMask($shape)
    {
        var __reg4 = $shape.width;
        var __reg3 = $shape.height;
        var __reg2 = $shape.cornerRadius;
        this._viewPanelMask = this._viewPanelMovieClip.createEmptyMovieClip("_viewPanelMask", this._viewPanelMovieClip.getNextHighestDepth());
        this._viewPanelMask.beginFill(0, 50);
        if (__reg2 > 0) 
        {
            this._viewPanelMask.moveTo(__reg2, 0);
            this._viewPanelMask.lineTo(__reg4 - __reg2, 0);
            this._viewPanelMask.curveTo(__reg4, 0, __reg4, __reg2);
            this._viewPanelMask.lineTo(__reg4, __reg3 - __reg2);
            this._viewPanelMask.curveTo(__reg4, __reg3, __reg4 - __reg2, __reg3);
            this._viewPanelMask.lineTo(__reg2, __reg3);
            this._viewPanelMask.curveTo(0, __reg3, 0, __reg3 - __reg2);
            this._viewPanelMask.lineTo(0, __reg2);
            this._viewPanelMask.curveTo(0, 0, __reg2, 0);
            this._viewPanelMask.lineTo(__reg2, 0);
        }
        else 
        {
            this._viewPanelMask.moveTo(0, 0);
            this._viewPanelMask.lineTo(__reg4, 0);
            this._viewPanelMask.lineTo(__reg4, __reg3);
            this._viewPanelMask.lineTo(0, __reg3);
            this._viewPanelMask.lineTo(0, 0);
        }
        this._viewPanelMask.endFill();
        this._viewPanelAssetWrapper.setMask(this._viewPanelMask);
    }

    function rerenderHitArea()
    {
        this._viewPanelHitArea = this.drawViewPanelHitArea(this._viewPanelMovieClip, this._viewPanelAssetWrapper);
        if (this._viewPanelAssetWrapper._height > 0 && this._viewPanelAssetWrapper._width > 0) 
        {
            clearInterval(this._hitAreaInterval);
        }
    }

}
